#!/usr/bin/env python
import os
import argparse
from subprocess import check_call

def main():
    parser = argparse.ArgumentParser(
        description="Builds all the Beats artifacts")
    parser.add_argument("--no-snapshot", action="store_true",
                        help="Don't append -SNAPSHOT to the version.")
    args = parser.parse_args()

    dir = os.path.dirname(__file__)
    os.chdir(dir + "/../")
    print("Getting dependencies")
    check_call("make clean", shell=True)
    print("Done building Docker images.")
    if args.no_snapshot:
        check_call("make release", shell=True)
    else:
        check_call("make snapshot", shell=True)
    print("All done")

if __name__ == "__main__":
    main()
